<#escape x as (x)!"">
package ${basePackage}.${plate}.${modulePackage}.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;


import ${basePackage}.entity.${modulePackage}.${className}Entity;
import ${basePackage}.${platPackage}.${modulePackage}.service.${className}Service;
import ${basePackage}.utils.Query;
import com.github.pagehelper.Page;
import ${basePackage}.result.Result;
import ${basePackage}.result.ResultGenerator;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * ${comments}
 * 
 * @author ${author}
 * @email ${email}
 * @date ${datetime}
 */
 @SuppressWarnings("rawtypes")
@RestController
@Api("${comments}")
@RequestMapping("${pathName}")
public class ${className}Controller {
	@Autowired
	private ${className}Service ${classname}Service;
	
	/**
	 * 列表
	 */
	@GetMapping("/list")
	@ApiOperation(value = "列表", notes = "说明")
	@ApiImplicitParams({
			@ApiImplicitParam(paramType = "query", dataType = "int", name = "page", value = "请求页", required = false),
			@ApiImplicitParam(paramType = "query", dataType = "int", name = "limit", value = "每页条数", required = false),
			@ApiImplicitParam(paramType = "query", dataType = "int", name = "sidx", value = "排序字段", required = false),
			@ApiImplicitParam(paramType = "query", dataType = "int", name = "order", value = "排序", required = false) })
	@RequiresPermissions("${pathName}:list")
	public Result list(@RequestParam Map<String, Object> params){

		// 查询列表数据
		Query query = new Query(params);
		Page<${className}Entity> page = ${classname}Service.queryPageList(query);
		return ResultGenerator.successPage(page);
	}
	
	
	/**
	 * 信息
	 */
	@GetMapping("/info/{${pk.attrname}}")
	@ApiOperation(value = "信息", notes = "说明")
	@RequiresPermissions("${pathName}:info")
	public Result info(@PathVariable("${pk.attrname}") ${pk.attrType} ${pk.attrname}){
		${className}Entity ${classname} = ${classname}Service.queryObject(${pk.attrname});
		
		return ResultGenerator.successData(${classname});
	}
	
	/**
	 * 保存
	 */
	@PostMapping("/save")
	@ApiOperation(value = "保存", notes = "说明")
	@RequiresPermissions("${pathName}:save")
	public Result save(@RequestBody ${className}Entity ${classname}){
		${classname}Service.save(${classname});
		
		return ResultGenerator.success("保存成功");
	}
	
	/**
	 * 修改
	 */
	@PostMapping("/update")
	@ApiOperation(value = "修改", notes = "说明")
	@RequiresPermissions("${pathName}:update")
	public Result update(@RequestBody ${className}Entity ${classname}){
		${classname}Service.update(${classname});
		
		return ResultGenerator.success("修改成功");
	}
	
	/**
	 * 删除
	 */
	@PostMapping("/delete")
	@ApiOperation(value = "删除", notes = "说明")
	@RequiresPermissions("${pathName}:delete")
	public Result delete(@RequestBody ${pk.attrType}[] ${pk.attrname}s){
		${classname}Service.deleteBatch(${pk.attrname}s);
		
		return ResultGenerator.success("删除成功");
	}
}
</#escape>